var length = $("#msg tr").length+1;
		  
		  function deleteRow(v){
			  v.parentNode.parentNode.removeChild(v.parentNode);
			  length = $("#msg tr").length+1;
			  if(length != null && length != ""){
					for(var i=0;i<length;i++){
						$("#msg tr:eq("+i+") th:eq(0)").text(i+1);
					}
				}
		  }

			function checkName(pageSize){
				var name = document.getElementById("zzmc").value;
				
					$.ajax({
						url:"judgeName.action",
						data:"name="+name,
						dataType:"JSON",
						type:"post",
						success:function(data){
							if(data.result){
								alert("字典名称已经存在！");
							}
						},
						error:function(err){
							alert(err.responseText);
						}
					})
			}
	
			function checkCode(pageSize){
				var code = document.getElementById("zdbh").value;
					$.ajax({
						url:"judgeCode.action",
						data:"code="+code,
						dataType:"JSON",
						type:"post",
						success:function(data){
							if(data.result){
								alert("字典编号已经存在！");
							}
						},
						error:function(err){
							alert(err.responseText);
						}
					})
			}
			
			function save(pageSize){
				if(confirm("确认新增业务字典？")){
					var name = document.getElementById("zzmc").value;
					var code = document.getElementById("zdbh").value;
					if(name == ''){
						alert("请输入字典名称！");
					}else if(code == ''){
						alert("请输入字典编号！");
					}else{    
					var result="";
					var b = false;
					var str = "";
					var str2 = "";
					$("#msg tr").each(function(i){
					    $(this).children("td").each(function(i){
					    	if(i>-1){
					    		if(i == 0 && $(this).text() == ''){
					    			b = true;
					    			str = '字典值不能为空！';	
					    		}else if(i == 1 && $(this).text() == ''){
					    			b = true;
					    			str2 = '字典内容不能为空！';
					    		}else{
					    			result+=$(this).text()+",";
					    		}
					    	}
					    });
					    result+=";";
					});
					
					if(result.length == 0){
						alert("请填写字典关联明细！");
					}else if(b){
						alert(str+str2);
					}else{
						var name = document.getElementById("zzmc").value;
						name = encodeURI(encodeURI(name));
						var code = document.getElementById("zdbh").value;
						code = encodeURI(encodeURI(code));
						result = encodeURI(encodeURI(result));
						window.location.href="insertSysdictAndSysdictItem.action?name="+name+"&code="+code+"&result="+result;
						//alert(pageSize);
						//$("#sysdict_sysdictItem_Form").submit();
					}
						
					}
				}
			}
			
			function addRow(){
				 
				$("#msg").append("<tr><th>"+length+"</th><td></td><td></td><th><button type='button' class=\"btn btn-mini btn-warning\" onclick=\"deleteRow(this.parentNode)\">删除行</button></th></tr>");
				$('#mainTable').editableTableWidget();
				length = $("#msg tr").length+1;
				if(length != null && length != ""){
					for(var i=0;i<length;i++){
						$("#msg tr:eq("+i+") th:eq(0)").text(i+1);
					}
				}
				$('#mainTable  td').on('change', function(evt, newValue) {
					// do something with the new cell value 
					//alert(evt.(0)+":"+newValue);

				});
			}